# -*- encoding:utf8 -*-
from attendance.models import AvaiLeave
from django.db.models import F

def swapoff_left(staff):
    """
    获取员工的当前剩余调休时间
    Return: int,分钟数
    """
    #now = datetime.now().date()
    #now_str = date2str(now)
    #three_month_ago = date2str(now - timedelta(days=90))
    span = 0
    for swap in AvaiLeave.objects.filter(staff=staff, category='swap_off',span__gt=F('used'), is_valid=True):
        span += swap.left()
    return span